<template>
<div class="div_main_frame" style="text-align:center;margin:0 auto;padding-top:0px" align="center">
<div class="fastweb_div_middle" style="width:100%;text-align:center;padding-right:6px;padding-top:0px">
    <div class="div_main_frame" style="width:100%;float:left;margin:auto;margin-top:0px;">
        <div class="div_main_frame" style="width:100%;margin:0px;padding:0px;">
            <ViewHeadSearch/>
            <div class="div_main_frame" style="text-align:left;margin-left:6px;width:98%;" align="center">
            <el-form  ref="formRef" :model="form" label-width="100px">
              <el-form-item label="用户标识：">
                <el-input v-model="user"></el-input>
                <!--el-col :span="8"-->
                <!--/el-col-->
              </el-form-item>
              <el-button type="primary" @click="queryUser">按用户查询</el-button>
              <!--el-form-item-->
                <p>&nbsp;&nbsp;网站不需要注册，请填写添加自定义实体集时的用户标识。</p>
              <!--/el-form-item-->
            </el-form>
            </div>
            <div class="div_main_frame" style="text-align:center;margin:0 auto" align="center">
                    <div class="content-data" style="text-align:left;width:100%;margin:0;padding:0;height:auto;font-size:18px;line-height:20px;">
                            <div class="div_link_rank_content" style="width:100%;border-top:1px solid gray;border-radius:0px;">
                                <div style="width:100%;float:left;line-height:56px;font-size:38px;">自定义实体集</div>
                                <div v-for="(d) in user_data" :key="d.name" style="width:100%;float:left;">
                                  <!--a :href="'#/entity_detail?name=' + entity" target="_blank">{{entity}}</a-->
                                  <!--a :href="'detail.html?name=' + d.name + '&user=' + user">{{d.name}}</a-->
                                  <router-link :to="{name:'detail', query: {name:d.name,user:user}}" target="_blank">{{d.name}}</router-link>
                                </div>
                                <div style="clear:both"></div>
                            </div>
                      
                    </div>
            </div>
            <ViewEntityList :json_data="json_data" />
        </div>
    </div>       
    <div style="clear:both"></div>
</div>
</div>
<ViewFooter/>
</template>

<script>
import { reactive } from 'vue'
import ViewFooter from '@/components/ViewFooter.vue'
import ViewEntityList from '@/components/ViewEntityList.vue'
import ViewHeadSearch from '@/components/ViewHeadSearch'
import { getCurrentInstance } from 'vue'
import "@/assets/global.css"
import "@/assets/fastweb.css"

  export default {
    name: 'PageEntityList',
    components: {
        ViewFooter,
        ViewEntityList,
        ViewHeadSearch,
    },
    data() {
      return {
        user:'',
        user_data:[],
        json_data:[],
      };
    },
    setup(){
      const host = getCurrentInstance()?.appContext.config.globalProperties.host
      return {host}      
    },
    methods: {
      queryUser() {
        var api_url = this.host.concat("/api/display_entity_list_by_user?user=").concat(this.user);
        this.axios.get(api_url)
        .then(response => {
          if((response.status == 200) && (response.data.result == 0)){
            console.log(response.data.data);
            this.user_data = JSON.parse(response.data.data);
          }
        })
        .catch(error => alert("系统错误，请稍后重试"));
      },
      queryData() {
        var api_url = this.host.concat("/api/display_entity_list");
        this.axios.get(api_url)
        .then(response => {
          if((response.status == 200) && (response.data.result == 0)){
            console.log(response.data.data);
            this.json_data = JSON.parse(response.data.data);
          }
        })
        .catch(error => alert("系统错误，请稍后重试"));
      }
    },
    mounted() {
      this.queryData();
    }
  };
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?c2ba86525ff37a3b2dd6cdadb129fdb5";
var s = document.getElementsByTagName("script")[0]; 
s.parentNode.insertBefore(hm, s);
</script>